package com.itHuangTao.tank.introduce;

import com.almasb.fxgl.app.scene.FXGLMenu;
import com.almasb.fxgl.app.scene.MenuType;
import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.texture.Texture;
import com.itHuangTao.tank.ui.HelpMenu;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;

public class Environment extends FXGLMenu {

    private static HBox brickBox, greensBox, seaBox, snowBox, stoneBox, flagBox;

    public Environment() {
        super(MenuType.GAME_MENU);

        StackPane pane = new StackPane();
        //设置窗口大小
        pane.setPrefSize(FXGL.getAppWidth(), FXGL.getAppHeight());
        //设置背景色(黑色)
        pane.setStyle("-fx-background-color: black");

        //环境方块介绍准备
        environmentPrepare();
        //放置间隔为30个像素
        VBox eBox = new VBox(30,brickBox,greensBox,seaBox,snowBox,stoneBox,flagBox);
        eBox.setLayoutX(50);
        eBox.setLayoutY(50);

        //按钮属性
        Button btnReturnLastMenu = new Button("返回上一级");
        btnReturnLastMenu.getStyleClass().add("menu-btn");//利用css设置样式
        btnReturnLastMenu.setOnAction(event -> {
            FXGL.getSceneService().pushSubScene(new HelpMenu());
        });
        //存放按钮属性
        VBox box = new VBox(30, btnReturnLastMenu);
        box.setLayoutX(FXGL.getAppWidth() / 2.0 - 100);
        box.setLayoutY(450);

        getContentRoot().getChildren()
                .addAll(pane, eBox, box);
    }

    //介绍准备
    private void environmentPrepare() {
        Text textBrick = new Text("\t砖块：一些简单的障碍物,一次就会被击毁");
        textBrick.setFill(Color.RED);
        textBrick.setFont(new Font("微软雅黑", 26));
        Texture textureBrick = FXGL.texture("map/brick.png");

        Text textGreens = new Text("\t森林：可以隐藏坦克，小心敌方在里面打黑枪");
        textGreens.setFill(Color.RED);
        textGreens.setFont(new Font("微软雅黑", 26));
        Texture textureGreens = FXGL.texture("map/greens.png");
        Text textSea = new Text("\t海洋：坦克无船具不可通行");
        textSea.setFill(Color.RED);
        textSea.setFont(new Font("微软雅黑", 26));
        Texture textureSea = FXGL.texture("map/sea.png");

        Text textSnow = new Text("\t雪地路面：除了装饰外没有什么用处");
        textSnow.setFill(Color.RED);
        textSnow.setFont(new Font("微软雅黑", 26));
        Texture textureSnow = FXGL.texture("map/snow.png");

        Text textStone = new Text("\t石块：非常坚硬的物体，没有最高级坦克不可击毁");
        textStone.setFill(Color.RED);
        textStone.setFont(new Font("微软雅黑", 26));
        Texture textureStone = FXGL.texture("map/stone.png");

        Text textFlag = new Text("     基地：这个是要你拼命保护的命根子");
        textFlag.setFill(Color.RED);
        textFlag.setFont(new Font("微软雅黑", 26));
        Texture textureFlag = FXGL.texture("map/flag.png");

        brickBox = new HBox(textureBrick, textBrick);
        greensBox = new HBox(textureGreens, textGreens);
        seaBox = new HBox(textureSea, textSea);
        snowBox = new HBox(textureSnow, textSnow);
        stoneBox = new HBox(textureStone, textStone);
        flagBox = new HBox(textureFlag, textFlag);
    }
}
